/*
 * 
 * Created on Sep 27, 2005
 */
package com.wgo.precise.client.ui.controller;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

/**
 * 
 * @author Petter L. H. Eide
 * @version $Id: PerspectiveFactoryImpl.java,v 1.1 2006-01-23 19:58:37 petterei Exp $
 */
public class PerspectiveFactoryImpl implements IPerspectiveFactory {

    public static final String LEFT_ID = "left" ;
    public static final String TOP_RIGHT_ID = "topRight" ;
    public static final String BOTTOM_RIGHT_ID = "bottomRight" ;
    

    /**
     * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
     */
    public void createInitialLayout(IPageLayout layout) {
        defineActions(layout);
        IFolderLayout left = defineLeftFolderLayout(layout);
        addExplorerToWorkbench(left);
    }

    private void defineActions(IPageLayout layout) {
        // Add "show views".
        layout.addShowViewShortcut(Registry.EXPLORER_PROJECT_TREE_ID);

        // Workbench
        layout.addShowViewShortcut(Registry.PROPERTIES_EDITOR_ID);
        
        //ActionSet
        layout.addActionSet(Registry.ACTIONSET_ID);

    }
    
    private IFolderLayout defineLeftFolderLayout(IPageLayout layout) {
    	IFolderLayout left;
//        IFolderLayout topRight;

    	
        String editorArea = layout.getEditorArea();

        left = layout.createFolder(LEFT_ID, IPageLayout.LEFT, (float) 0.28, editorArea) ;
//        topRight = layout.createFolder(TOP_RIGHT_ID, IPageLayout.BOTTOM, (float) 0.20, editorArea);
//        topRight = layout.createFolder(TOP_RIGHT_ID, IPageLayout.TOP, (float) 0.50, editorArea);

        layout.addActionSet(Registry.ACTIONSET_ID);
        return left;
    }
    
    /**
     * To be called when user logs in. Sets up requirement-views.
     */
    private void addExplorerToWorkbench(IFolderLayout layout) {
        layout.addView(Registry.EXPLORER_PROJECT_TREE_ID);
        
//        topRight.addPlaceholder(Registry.PROPERTIES_EDITOR_ID);
//        topRight.addPlaceholder(IPageLayout.ID_PROP_SHEET);
    }

}
